/*********************************************************
 *  Copyright (c) 2011 by Web Information Systems (WIS) Group, 
 *  Delft University of Technology.
 *  Qi Gao, http://wis.ewi.tudelft.nl/index.php/home-qi-gao
 *  
 *  Some rights reserved.
 *
 *  Contact: q.gao@tudelft.nl
 *
 **********************************************************/
package org.persweb.genius;

import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;

import org.persweb.genius.model.Concept;

/**
 * @author Qi Gao <a href="mailto:q.gao@tudelft.nl">q.gao@tudelft.nl</a>
 * @version created on Jun 27, 2011 11:15:41 AM
 */
public class GenericModelingUtility {

	/**
	 * @param res
	 * @return
	 */
	public static HashMap<Concept, Double> normalizeProfile(
			HashMap<Concept, Double> res) {
		double maxValue = Collections.max(res.values());
		if(maxValue > 0.0){
		Iterator<Concept> it = res.keySet().iterator();
		while(it.hasNext()){
			Concept key = it.next();
			double newValue = res.get(key)/maxValue;
			res.put(key, newValue);
		}
		return res;
		} else{
			return res;
		}
		
	}
}
